// pages/product/goods/goodsDetail/goodsDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: { 
    goodsId:'',
    baseUrl: 'http://140.143.18.217:8080',
    loadImageUrl: '/product/img/loadImg/', 
    goodsUrl: '/product/goods/getGoods/',
    typeListUrl: '/product/dict/findByType',
    goodsDto:null,
    imgUrls: [
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
 
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    var id = wx.getStorageSync('goodsId');
    this.setData({ goodsId: id });
    this.loadGoods(); 
  },

  loadGoods:function(){
    var sendUrl = this.data.baseUrl + this.data.goodsUrl + this.data.goodsId;
    var that = this;
    wx.request({
      url: sendUrl, 
      method: 'post',
      success: function (res) {
        wx.showToast({ title: '加载成功' }); 
        console.log('success getGoods:' + res.data.data[0]);
        //设置商品
        that.setData({
          goodsDto: res.data.data[0]
        })
      },
      fail: function (res) {
        wx.showToast({ title: res });
      }
    });


  }
  
})